﻿//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Text;
//using Newtonsoft.Json;
//namespace Framework.Serializer
//{
//    class NewtonsoftJsonSerializer : StringSerializeBase
//    {
//        static Newtonsoft.Json.JsonSerializer Js = new Newtonsoft.Json.JsonSerializer
//        {
//            ObjectCreationHandling = ObjectCreationHandling.Replace,
//            MissingMemberHandling = MissingMemberHandling.Ignore,
//            ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
//            PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects
//        };

//        /// <summary>
//        /// 序列化
//        /// </summary>
//        /// <param name="obj"></param>
//        /// <returns></returns>
//        public override string Serialize(object obj)
//        {
//            if (obj == null) return "{}";

//            using (StringWriter sw = new StringWriter())
//            {
//                Js.Serialize(sw, obj);
//                string result = sw.ToString();
//                return result;
//            }
//        }

//        /// <summary>
//        /// 反序列化
//        /// </summary>
//        /// <typeparam name="T"></typeparam>
//        /// <param name="source"></param>
//        /// <returns></returns>
//        public override T DeSerialize<T>(string source)
//        {
//            using (StringReader sr = new StringReader(source))
//            {
//                T t = (T)Js.Deserialize(sr, typeof(T));
//                return t;
//            }
//        }
//    }
//}
